package com.example.win.android_banduyujia.venuesactivity.activity.classactivity;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.example.win.android_banduyujia.R;
import com.example.win.android_banduyujia.lib.util.StrUtils;
import com.example.win.android_banduyujia.peopleactivity.ui.activity.BaseTitleBarActivity;

/**
 * Created by Win on 2015/9/10.
 */
public class ClassesPriceActivity extends BaseTitleBarActivity {

    private EditText  mEditPrice;
    private ImageView mImageCancel;
    private String    mNickPrice = " ";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_price_page);

        InitTitles();
        InitViews();
    }

    private void InitTitles() {
        showLeftBackButton();
        setTitle(R.string.layout_edit_hint_price);
        setRightTextViewListener(R.string.layout_data_save_button, mRightListener);
    }

    private View.OnClickListener mRightListener = new View.OnClickListener(){

        @Override
        public void onClick(View v) {
            if(StrUtils.isEmpty(mNickPrice)){
                showToast(R.string.layout_edit_hint_price);
                return;
            }
            save();
        }
    };

    private void save() {

    }

    private void InitViews() {
         mEditPrice = (EditText) findViewById(R.id.update_price_edit_text);
         mImageCancel = (ImageView) findViewById(R.id.update_price_image_icon);

         mImageCancel.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 mEditPrice.setText(" ");
             }
         });

        mEditPrice.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                 mNickPrice = s.toString();
                 if(StrUtils.isEmpty(mNickPrice)){
                     mImageCancel.setVisibility(View.GONE);
                 }else{
                     mImageCancel.setVisibility(View.VISIBLE);
                 }
            }
        });
    }
}
